package cn.yunchongbao.charging.device.controller;


import cn.yunchongbao.charging.common.pojo.JsonResult;
import cn.yunchongbao.charging.common.pojo.vo.StationInfoVo;
import cn.yunchongbao.charging.common.pojo.vo.GunStatusUpdateParam;
import cn.yunchongbao.charging.device.service.DeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RequestMapping("/device")
@RestController
@Api(tags = "设备接口")
public class DeviceController {
    @Autowired
    private DeviceService deviceService;

    @GetMapping("/station/info/{gunId}")
    @ApiOperation("获取场站信息")
    public JsonResult getStationInfo(@PathVariable("gunId") Integer gunId){
        log.debug("获取场站信息入参：{}", gunId);
        StationInfoVo stationInfoVo = deviceService.getStationInfo(gunId);
        log.debug("获取场站信息入参：{}，出参：{}", gunId, stationInfoVo);
        JsonResult jsonResult = JsonResult.ok(stationInfoVo,"获取场站信息成功");
        return jsonResult;
    }

    @PostMapping("/station/gun/status/update")
    @ApiOperation("更新充电枪状态")
    public JsonResult gunStatusUpdate(@RequestBody GunStatusUpdateParam gunStatusUpdateParam){
        log.debug("更新充电枪状态入参：{}", gunStatusUpdateParam);
        Boolean success = deviceService.updateGunStatus(gunStatusUpdateParam);
        log.debug("更新充电枪状态入参：{}，出参：{}", gunStatusUpdateParam, success);
        JsonResult jsonResult = JsonResult.ok(success,"更新充电枪状态成功");
        return jsonResult;
    }
}
